<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>rush jd cloud</title>
</head>
<link th:href="@{/layui-v2.5.5/layui/css/layui.css}" rel="stylesheet"/>
<script type="text/javascript" th:src="@{/layui-v2.5.5/layui/layui.js}"></script>
<body style="height: 100%; width: 100%">
<form class="layui-form" action="" lay-filter="example" style="margin-top: 20px">
    <div class="layui-form-item">
        <label class="layui-form-label">cookie</label>
        <div class="layui-input-block">
            <input type="text" name="cookie" lay-verify="title" autocomplete="off" placeholder="cookie" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">param</label>
        <div class="layui-input-block">
            <input type="text" name="param" placeholder="param" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">targetUrl</label>
        <div class="layui-input-block">
            <input type="text" name="targetUrl" placeholder="targetUrl" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">referer</label>
        <div class="layui-input-block">
            <input type="text" name="referer" placeholder="referer" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">开始时间(yyyy-MM-dd HH:mm:ss:SSS)</label>
        <div class="layui-input-block">
            <input type="text" name="rushDate" placeholder="rushDate" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">每次抢的间隔时间(ms)</label>
        <div class="layui-input-block">
            <input type="text" name="interval" placeholder="interval" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>
</body>
<script>
    layui.use(['form',"jquery"], function(){
        var form = layui.form
            ,$ = layui.jquery;

        form.on('submit(demo1)', function(data){
            var field = data.field;
            var data = {
                cookie: field.cookie,
                param: field.param,
                rushDate: field.rushDate,
                interval: field.interval
            }
            $.ajax({
                type: "POST",
                url: "/rush/data",
                data: data,
                dataType: 'json',
                success: function(result) {
                    if (result.code === '0') {
                        layer.confirm('修改成功,确认后回到首页!', {icon: 3, title:'提示'}, function(index){
                            layer.close(index);
                            location.href = '/rush/index';
                        });

                    } else {
                        layer.alert("修改失败!");
                    }
                },
                error: function(error) {
                }
            });
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            return false;
        });
    })
</script>
</html>
